package domain;

import java.lang.reflect.Field;

import org.codehaus.jackson.JsonNode;

public class Task extends JSONABLE{
	
	public static enum Type{
		CPP,
		CS,
		JAVA;
	}
	
	public static enum Status{
		FREE,
		PROCESS,
		READY;
	}
	

	public int coordinate;
	
	public String type;
	
	public int duration;
	
	public int remaining;
	
	public int profit;
	
	public int penalty;
	
	public String status;
	
	public Task(JsonNode jsonNode) {
		
		this.coordinate = jsonNode.get("coordinate").asInt();
		this.type = jsonNode.get("type").asText();
		this.duration = jsonNode.get("duration").asInt();
		this.remaining = jsonNode.get("remaining").asInt();
		this.profit = jsonNode.get("profit").asInt();
		this.penalty = jsonNode.get("penalty").asInt();
		
	}

	public Status getStatus(){
		if("free".equals(status))
			return Status.FREE;
		else if("process".equals(status))
			return Status.PROCESS;
		else 
			return Status.READY;
	}
	
	public Type getType(){
		
		if("java".equals(type))
			return Type.JAVA;
		else if("c++".equals(type))
			return Type.CPP;
		else
			return Type.CS;
	}
	
	public boolean isFree(){
		return "free".equals(status);
	}
	
	public boolean isReady(){
		return "ready".equals(status);
	}
	
	public boolean isPotential(){
		// TODO
		return true;
	}
	
}
